﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/AdminPage.master" AutoEventWireup="true" CodeFile="Mail_Management.aspx.cs" Inherits="Admin_Mail_Management" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <div id="head">
    <asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="White" 
        Text="Mail Management"></asp:Label>
    <table style="width: 100%">
        <tr>
            <td style="width: 112px">
                &nbsp;</td>
            <td align="right">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td align="right" colspan="2" class="style7">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td align="right" style="width: 112px" class="style7">
                <asp:Label ID="Label2" runat="server" Font-Bold="True" ForeColor="Black" 
                    Text="ID Mail"></asp:Label>
            </td>
            <td>
                <asp:TextBox ID="txtSearch" runat="server" Width="350px"></asp:TextBox>
            </td>
            <td>
                <asp:ImageButton ID="imgbSearch" runat="server" 
                    ImageUrl="~/images/img_Search.png" onclick="imgbSearch_Click" 
                    ValidationGroup="Search" />
                <asp:ImageButton ID="imgbShowAll" runat="server" Height="34px" 
                    ImageUrl="~/images/img_Show All.png" Width="105px" 
                    onclick="imgbShowAll_Click" />
            </td>
        </tr>
        <tr>
            <td style="width: 112px">
                &nbsp;</td>
            <td>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                    ControlToValidate="txtSearch" ErrorMessage="You must be enter digits" 
                    ForeColor="Red" SetFocusOnError="True" ValidationExpression="[0-9]+" 
                    ValidationGroup="Search"></asp:RegularExpressionValidator>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 112px">
                &nbsp;</td>
            <td>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtSearch" 
                    ErrorMessage="You did not enter a valid sender phone" ForeColor="Red" 
                    ValidationGroup="Search"></asp:RequiredFieldValidator>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td colspan="3">
                <asp:GridView ID="gvMail" runat="server" AutoGenerateColumns="False" 
                    CellPadding="4" DataKeyNames="MailID" DataSourceID="SqlDataSource1" 
                    ForeColor="#333333" GridLines="None" onrowcommand="gvMail_RowCommand" 
                    Width="700px" AllowPaging="True" AllowSorting="True" 
                    EmptyDataText="No data. Please enter id mail again">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:BoundField DataField="MailID" HeaderText="ID" InsertVisible="False" 
                            ReadOnly="True" SortExpression="MailID" />
                        <asp:BoundField DataField="SenderName" HeaderText="Sender Name" 
                            SortExpression="SenderName" />
                        <asp:BoundField DataField="DateReceipt" HeaderText=" Receipt" 
                            SortExpression="DateReceipt" />
                        <asp:BoundField DataField="DateDelivery" HeaderText="Delivery" 
                            SortExpression="DateDelivery" />
                        <asp:BoundField DataField="Status" HeaderText="Status" 
                            SortExpression="Status" />
                        <asp:BoundField DataField="isSendEmail" HeaderText="SendEmail" 
                            SortExpression="isSendEmail" />
                        <asp:BoundField DataField="TotalFee" HeaderText="Total Fee" 
                            SortExpression="TotalFee" />
                        <asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/img_Delete.png" 
                            ShowDeleteButton="True" />
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:ImageButton ID="ImageButton1" runat="server" 
                                    CommandArgument='<%# Eval("MailID") %>' CommandName="Details" 
                                    ImageUrl="~/images/img_Details.png" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                  
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:OPOConnectionString %>" 
                    DeleteCommand="DELETE FROM [Mail] WHERE [MailID] = @MailID" 
                    InsertCommand="INSERT INTO [Mail] ([DateReceipt], [DateDelivery], [Status], [isSendEmail], [SenderName], [TotalFee]) VALUES (@DateReceipt, @DateDelivery, @Status, @isSendEmail, @SenderName, @TotalFee)" 
                    SelectCommand="SELECT [MailID], [DateReceipt], [DateDelivery], [Status], [isSendEmail], [SenderName], [TotalFee] FROM [Mail] WHERE ([MailID] = @MailID)" 
                    UpdateCommand="UPDATE [Mail] SET [DateReceipt] = @DateReceipt, [DateDelivery] = @DateDelivery, [Status] = @Status, [isSendEmail] = @isSendEmail, [SenderName] = @SenderName, [TotalFee] = @TotalFee WHERE [MailID] = @MailID">
                    <DeleteParameters>
                        <asp:Parameter Name="MailID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="DateReceipt" Type="String" />
                        <asp:Parameter Name="DateDelivery" Type="String" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="isSendEmail" Type="String" />
                        <asp:Parameter Name="SenderName" Type="String" />
                        <asp:Parameter Name="TotalFee" Type="Double" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtSearch" Name="MailID" PropertyName="Text" 
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="DateReceipt" Type="String" />
                        <asp:Parameter Name="DateDelivery" Type="String" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="isSendEmail" Type="String" />
                        <asp:Parameter Name="SenderName" Type="String" />
                        <asp:Parameter Name="TotalFee" Type="Double" />
                        <asp:Parameter Name="MailID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:OPOConnectionString %>" 
                    DeleteCommand="DELETE FROM [Mail] WHERE [MailID] = @MailID" 
                    InsertCommand="INSERT INTO [Mail] ([DateReceipt], [DateDelivery], [Status], [isSendEmail], [SenderName], [TotalFee]) VALUES (@DateReceipt, @DateDelivery, @Status, @isSendEmail, @SenderName, @TotalFee)" 
                    SelectCommand="SELECT [MailID], [DateReceipt], [DateDelivery], [Status], [isSendEmail], [SenderName], [TotalFee] FROM [Mail]" 
                    UpdateCommand="UPDATE [Mail] SET [DateReceipt] = @DateReceipt, [DateDelivery] = @DateDelivery, [Status] = @Status, [isSendEmail] = @isSendEmail, [SenderName] = @SenderName, [TotalFee] = @TotalFee WHERE [MailID] = @MailID">
                    <DeleteParameters>
                        <asp:Parameter Name="MailID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="DateReceipt" Type="String" />
                        <asp:Parameter Name="DateDelivery" Type="String" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="isSendEmail" Type="String" />
                        <asp:Parameter Name="SenderName" Type="String" />
                        <asp:Parameter Name="TotalFee" Type="Double" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="DateReceipt" Type="String" />
                        <asp:Parameter Name="DateDelivery" Type="String" />
                        <asp:Parameter Name="Status" Type="String" />
                        <asp:Parameter Name="isSendEmail" Type="String" />
                        <asp:Parameter Name="SenderName" Type="String" />
                        <asp:Parameter Name="TotalFee" Type="Double" />
                        <asp:Parameter Name="MailID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td style="width: 112px">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td style="width: 112px">
                &nbsp;</td>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    </div>
</asp:Content>

